#!/bin/sh

compiz_on () {
    compiz --replace &
        #gconf

    which gnome-window-decorator && gnome-window-decorator &
    which avant-window-navigator && { sleep 3; avant-window-navigator & }
    }

compiz_off () {
    killall -TERM gnome-window-decorator
    killall -TERM avant-window-navigator
    metacity --replace &
    }

compiz_status () {
    ps -C compiz.real > /dev/null
    return $?
    }


case "$1" in
    (on)
        compiz_status || compiz_on
        ;;
    (off)
        compiz_status && compiz_off
        ;;
    (switch)
        compiz_status && compiz_off || compiz_on
        ;;
    (status)
        compiz_status
        exit $?
        ;;
    (*)
        echo "Usage: ${0##*/} on|off|switch|status" 2>&1
        exit 2
        ;;
    esac
